<?php
use Jialeo\LaravelSchemaExtend\Schema;
//use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_orders', function (Blueprint $table) {
            $table->comment = '订单表';
            $table->increments('id')->comment('订单ID');
			$table->integer('user_id')->comment('用户ID');
			$table->string('order_no',100)->unique()->default('')->comment('订单号');
			$table->string('refund_no',100)->nullable()->comment('退款订单号');
			$table->decimal('refund_money',8,2)->default('0.00')->comment('退款金额');
			$table->string('refund_comment',100)->nullable()->comment('退款备注');
			$table->tinyInteger('status')->default(1)->comment('订单状态：1=待付款（可取消订单），2=待发货，3=待收货，4=待评价，5=订单已取消，6=申诉中，7=申诉失败，8=申诉完成，9=已完成（可申诉）');
			$table->tinyInteger('open')->default(0)->comment('是否查看，0=否，1=是');
			$table->decimal('total_money',8,2)->default('0.00')->comment('订单总金额：包括运费');
			$table->decimal('deliver_money',8,2)->default('0.00')->comment('运费：运费规则按照每个规格计算');
			
			$table->tinyInteger('total_num')->comment('购买总数量');
			$table->tinyInteger('pay_from')->default(2)->comment('支付来源：1=钱包，2=微信小程序，3=微信H5');
			$table->tinyInteger('type')->default(1)->comment('平台类型：1=微信小程序，2=抖音小程序');
			$table->string('user_name',30)->default('')->comment('收货人名称');
			$table->string('user_address',100)->default('')->comment('收件人地址');
			$table->string('user_phone',30)->default('')->comment('收件人手机');
			$table->integer('province_id')->comment('省ID');
			$table->string('province_name',100)->default('')->comment('省名称');
            $table->integer('city_id')->comment('市ID');
			$table->string('city_name',100)->default('')->comment('市名称');
            $table->integer('county_id')->comment('区/县ID');
			$table->string('county_name',100)->default('')->comment('区/县名称');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('receive_time')->nullable()->comment('评价时间');
			$table->timestamp('delivery_time')->nullable()->comment('发货时间');
			$table->timestamp('pay_time')->nullable()->comment('付款时间');
			$table->string('prepay_id',100)->nullable()->comment('微信支付预订单id');
			$table->string('serial_number',100)->nullable()->comment('支付平台流水号');
			$table->string('comment',100)->nullable()->comment('备注');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_orders');
    }
}
